package com.billProvider.controller;

import entity.Bill;
import entity.ResponseMessage;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import service.financial.FinaBillService;

import java.util.Map;

/**
 * @author oahner
 * @create 2022-04-18 10:09
 */
@RestController
@CrossOrigin
@RequestMapping("finabill")
public class FinaBillProviderController {

    private Logger logger = Logger.getLogger(getClass());

    @Autowired
    private FinaBillService finaBillService;


    /**
     * 获取财务账单列表
     * @param billPage
     * @return
     */
    @RequestMapping("getFinaBill")
    public ResponseMessage getFinaBill(@RequestBody Map<String,Object> billPage){
        logger.info("FinaBillProviderController getFinaBill params:billPage="+billPage);
        ResponseMessage msg = finaBillService.getFinaBill(billPage);
        logger.debug("FinaBillProviderController getFinaBill result:msg="+msg);
        return msg;
    }

    /**
     * 获取最近7天财务账单，渲染折线图
     * @param
     * @return
     */
    @RequestMapping("getFinaBillInLastW")
    public ResponseMessage getFinaBillInLastW(){
        logger.info("FinaBillProviderController getFinaBillInLastW init===================");
        ResponseMessage msg = finaBillService.getFinaBillInLastW();
        logger.debug("FinaBillProviderController getFinaBillInLastW result:msg="+msg);
        return msg;
    }

    /**
     * 获取上月财务账单，渲染饼图
     * @param
     * @return
     */
    @RequestMapping("getFinaBillInLastM")
    public ResponseMessage getFinaBillInLastM(){
        logger.info("FinaBillProviderController getFinaBillInLastM init===================");
        ResponseMessage msg = finaBillService.getFinaBillInLastM();
        logger.debug("FinaBillProviderController getFinaBillInLastM result:msg="+msg);
        return msg;
    }

    /**
     * 获取去年财务账单，渲染饼图
     * @param
     * @return
     */
    @RequestMapping("getFinaBillInLastY")
    public ResponseMessage getFinaBillInLastY(){
        logger.info("FinaBillProviderController getFinaBillInLastY init===================");
        ResponseMessage msg = finaBillService.getFinaBillInLastY();
        logger.debug("FinaBillProviderController getFinaBillInLastY result:msg="+msg);
        return msg;
    }



}
